<?php if (!defined('CORE_DIR')) die('Wrong entry point!');

/* 
 * Copyright 2010 Anton Muraviev a.k.a kuromaisu
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

Aero::register('testAppContext','/testApp');

// Display all errors
Aero::load('libs/errors/display');

// URI rewrite rules
Aero::setOption('uri.routes',array(
	'test_request/rewrite/into/another/uri' => 'test_request/another/uri',
	'test_request/rewrite/:num:/:any:' => 'test_request/:2:/:1:',
	'form/with/style' => 'test_forms'
));
$Request = Aero::load('libs/request');

if ($Request->uri->slice() === '')
{
	// Lets start testing...
	Aero::load('libs/specification');
	
	AeroSpec::setName('Aero specifications');
	Aero::load('specs/specification_spec');
	Aero::load('specs/core_spec');
	Aero::load('specs/pipeline_spec');
	Aero::load('specs/diff_spec');
	Aero::load('specs/dom_spec');
	Aero::load('specs/database_spec');
	Aero::load('specs/request_spec');
	Aero::load('specs/uri_spec');
	Aero::load('specs/response_spec');
	Aero::load('specs/view_spec');
	Aero::load('specs/validator_spec');
	Aero::load('specs/localisation_spec');
	Aero::load('specs/markdown_tests/markdown');
	Aero::load('specs/markdown_tests/markdown_extra');

	AeroSpec::report();
}
else try {
	$Request->uri->route('actions');
} catch (RequestException $e) {
	Aero::load('libs/response')->error(404);
}
